package org.dbrd;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Config {
	
	public static boolean IDENTIFYING_PROCESSING = false;

	public static enum EnumEnsemblingStrategy {
		MAX, MIN, AVG
	}
	
	public static final EnumEnsemblingStrategy ENSEMBLING_TYPE = EnumEnsemblingStrategy.AVG;

	public static final String LINE_SEPARATOR = System.getProperty("line.separator");

	public static final int RANDOM_SEED = 100;

	// private static int sequence;

	public static final int TOP_NUMBER = 20;

	// private static WeakHashMap<Thread, Integer> threadMap = new
	// WeakHashMap<Thread, Integer>();

	static final File DRIVE = new File("R:/");

	// private static final String PREFIX = new
	// SimpleDateFormat("HH-mm-ss").format(new Date());

	// private static final File DIRECTORY = new File(DRIVE, PREFIX);

	//	
	// private static synchronized int getSequence() {
	// Integer i = threadMap.get(Thread.currentThread());
	// if (i == null) {
	// i = sequence++;
	// threadMap.put(Thread.currentThread(), i);
	// }
	// return i;
	// }

	public static final int SVM_TRAIN_CACHE_SIZE = 500;

	public static final boolean USING_N_GRAM = false;

	public static final String OPENOFFICE_SUMMARY_REPORT_PATH = "openoffice-report-summary.txt";

	public static final String ECLIPSE_SUMMARY_REPORT_PATH = "eclipse-report-summary.txt";
	
	public static final String FIREFOX_SUMMARY_REPORT_PATH = "firefox-report-summary.txt";
	// public static final String OPENOFFICE_BUG_REPORT_DIRECTORY =
	// "F:\\work\\workspace\\dup-bug-detector\\openoffic-bug-reports";

	public static final String OPENOFFICE_BUG_REPORT_DIRECTORY = "F:\\work\\workspace\\dup-bug-detector\\openoffic-bug-reports";

	public static final String ECIPSE_BUG_REPORT_DIRECTORY = "F:\\work\\workspace\\dup-bug-detector\\eclipse-bug-reports";

	public static final String FIREFOX_BUG_REPORT_DIRECTORY = "F:\\work\\workspace\\dup-bug-detector\\firefox-bug-reports";
	
	public static final String PARAPHRASE_FILE = new File(DRIVE, "new-words.txt").getAbsolutePath();
	
	private static Config CURRENT;

	public static Config getCurrent() {
		if (CURRENT == null) {
			return create();
		}
		return CURRENT;
	}

	/********************************************************************************************
	 * object methods and fields.
	 ********************************************************************************************/
	private File directory;

	private static int sequence;

	public Config() {
		sequence++;
	}

	protected File getDirectory() {
		if (directory == null) {
			directory = new File(DRIVE, new SimpleDateFormat("HH-mm-ss").format(new Date()));
			if (!directory.exists()) {
				directory.mkdirs();
			}
		}
		return directory;
	}

	public static final Config create() {
		CURRENT = new Config();
		return CURRENT;
	}

	public String getDefaultResultPath() {
		// return "r:/" + PREFIX + "(" + getSequence() +
		// ")detection-result.txt";
		return new File(getDirectory(), sequence + "-detection-result.txt").getAbsolutePath();
	}

	public static final boolean CHECKING = false;

	public static final int CLASSIFIER_COUNT = 8;

	public static final boolean ANALYZE_FEATURE = false;

	public File getTrainingFilePath() {
		// return new File("r:/" + PREFIX + "(" + getSequence() +
		// ")training_set.txt");
		return new File(getDirectory(), sequence + "-training_set.txt");
	}

	public File getTrainingFilePath(int prefix) {
		return new File(getDirectory(), sequence + "-" + prefix + "-training_set.txt");
	}

	public File getTestingFilePath() {
		// return new File("r:/" + PREFIX + "(" + getSequence() +
		// ")testing_set.txt");
		return new File(getDirectory(), sequence + "-testing_set.txt");
	}

	public File getTestingMappingFilePath() {
		// return new File("r:/" + PREFIX + "(" + getSequence() +
		// ")testing_set.mapping");
		return new File(getDirectory(), sequence + "-testing_set.mapping");
	}

	public File getOnlineAnalysisFilePath() {
		// return new File("r:/" + PREFIX + "(" + getSequence() +
		// ")online-analysis.oas");
		return new File(getDirectory(), sequence + "-online-analysis.oas");
	}

	public File getFeatureSelectionAnalysisFilePath() {
		return new File(getDirectory(), sequence + "-feature-analysis.txt");
	}
	
}
